#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define lld long long // long long 的 printf 占位符是 lld
#define ENDL '\n'     // 将 endl 替换为 \n 取消缓冲区

using std::cin;
using std::cout;
using std::vector;
inline int read();
inline int put();
void solve() {
  int n, k;
  n = read();
  k = read();
  vector<int> s(n);
  for (auto &i : s)
    i = read();
  auto cmp = [](int a, int b) { return a < b; };
  auto LOG_DEBUG = [](lld x) { printf("x is %lld\n", x); };
  /*
  for(auto x:s)
    LOG_DEBUG(x);
  */

  std::sort(s.begin(), s.end(), cmp);
  int ans = 1;
  int sum = 0;

  int L = 0;
  for (int R = 1; R < n; ++R) {
    int opt = (R - L) * (s[R] - s[R - 1]);
    sum += opt;
    while (sum > k) {
      sum = sum - (s[R] - s[L]);
      L++;
    }
    ans = std::max(ans, R - L + 1);
  }

  /* ans = 1;
  sum = 0;

  int R = 1;
  for (int L = 0; L < n; L++) {
    if (R <= L)
      R = L + 1;
    while (R < n) {
      int opt = (R - L) * (s[R] - s[R - 1]);
      sum += opt;
      // 非法 倒退回去
      if (sum > k) {
        sum = sum - (s[R] - s[L]);
        break;
      }
      // 合法 继续前进
      else {
        ans = std::max(ans, R - L + 1);
        R++;
      }
    }
  } */

  cout << ans << ENDL;
}
int main() {
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
}
// int read 和lld 类型的 put
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}

inline void put(lld x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    put(x / 10);
  putchar(x % 10 + '0');
}
/*
input
5
1 0
1
2 1
1 2
3 1
1 2 2
5 2
1 3 3 4 5

output
1
2
3
4

*/